package sv.mecca.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import sv.mecca.form.Clinica4Form;
import sv.mecca.modelo.Clinica4Modelo;

public class Clinica4Action extends DispatchAction{
	Clinica4Modelo oper = new Clinica4Modelo();
	
	public void insertar(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		oper.saveClinica4((Clinica4Form) form);
		this.listado(mapping, form, request, response);
	}
	
	public void actualizar(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		oper.updateClinica4((Clinica4Form) form);
		this.listado(mapping, form, request, response);
	}
	
	public void eliminar(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		oper.deleteClinica4((Clinica4Form) form);
		this.listado(mapping, form, request, response);
	}
	
	public void listado(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		request.setAttribute("clinica4List", oper.listado());
		((Clinica4Form) form).destroy();
		request.getRequestDispatcher("/Definiciones/Clinica4.jsp").forward(
				request, response);
	}
}
